<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <base href="http://localhost:8080/file_upload_war_exploded/">
    <link rel="stylesheet" href="static/css/bootstrap.css">
    <style>
        .btn-outline-primary {
            padding: 10px 22px;
        }
    </style>
</head>
<body>
<div class="container col-6">
    <form>
        <div class="form-group mt-3">
            <label for="account">用户名</label>
            <input type="text" class="form-control" id="account" aria-describedby="emailHelp">
        </div>
        <div class="form-group mt-3">
            <label for="password">密码</label>
            <input type="password" class="form-control" id="password">
        </div>
        <div class="form-group mt-3">
            <button type="button" id="login" class="btn btn-primary">登录</button>
            <button type="reset" class="btn btn-outline-primary">重置</button>
        </div>
    </form>
</div>

<script src="static/js/jquery-3.5.1.js"></script>
<script !src="">
    $(function () {
        $("#login").click(function () {
            $.ajax({
                url: "user/login",
                type: "POST",
                data: {
                    account: $("#account").val(),
                    password: $("#password").val()
                },
                dataType: "json",
                success: function (data) {
                    console.log(data)
                    if (data.id != 0) {
                        alert("登录成功!");
                        location.href = "user/listPage";
                    } else {
                        alert("登录失败");
                    }
                },
                error: function (e) {
                    alert("登录失败,发生错误!" + e);
                }
            })
        })
    });
</script>
</body>
</html>
